<!DOCTYPE html>
<html xmlns:fb="http://ogp.me/ns/fb#" lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes" />

        <title>Bdnews24.com</title>
        <link rel="stylesheet" href="stylesheets/screen.css" media="Screen" type="text/css" />
        <link rel="stylesheet" href="stylesheets/mobile.css" media="handheld, only screen and (max-width: 480px), only screen and (max-device-width: 480px)" type="text/css" />

        <!--[if IEMobile]>
        <link rel="stylesheet" href="mobile.css" media="screen" type="text/css"  />
        <![endif]-->

        <!-- These are Open Graph tags.  They add meta data to your  -->
        <!-- site that facebook uses when your content is shared     -->
        <!-- over facebook.  You should fill these tags in with      -->
        <!-- your data.  To learn more about Open Graph, visit       -->
        <!-- 'https://developers.facebook.com/docs/opengraph/'       -->

        <meta property="og:title" content="Bdnews24" />          
        <meta property="og:type" content="article" />
        <meta property="og:url" content="http://apps.facebook.com/bdnews_twenty_four/" />
        <meta property="og:image" content="http://apps.facebook.com/bdnews_twenty_four/logo.png" />
        <meta property="og:site_name" content="Bdnews24.com" /> 
        <meta property="og:description" content="Official facebook app for bdnews24" />
        <meta property="fb:app_id" content="315241705214029" />

        <script type="text/javascript" src="javascript/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="javascript/myScript.js"></script>

    </head>
    <body>

        <div id="fb-root"></div>

        <div id="content">


            <div id="heading" align="center">
                <a href="index.php"><img src="images/heading.gif"/></a>
            </div>


            <div id="bangla">

                <div id="e_to_b">
                    <a href="bangla_index.php"><img src="images/bangla.gif"></a>
                </div>


                <div id="join" onclick="requestToFriends();">
                    <a href="#" class="inviteFriend">Invite Your Friends</a>
                </div>

            </div>

            <div id="feedData">


                <?php

                /**
                 *
                 * @param type $feed_url
                 * @param type $category
                 * @return string 
                 */
                function feed_to_html($feed_url, $category) {
                    $i = 0;
                    $content = file_get_contents($feed_url) . "</rss>";
                    $xml_data = new SimpleXMLElement($content);

                    if ($category == 0) {
                        $output = '<ul style="list-style:none">';
                    } else {
                        $output = '<ul style="list-style:none; width:220px">';
                    }
                    foreach ($xml_data->content->item as $news) {
                        $output .='<li>';

                        $title = $news->title;
                        $url = $news->link;
                        $img_src = $news->image;

                        $id = substr($url, 39, 6);

                        $image = '<img src="' . $img_src . '" height="144" width="180" />';
                        $news_heading = '<a href="readArticle.php?index=' . $id . '&category=' . $category . '">' . $title . '</a><br/>';

                        if ($category == 0) {
                            $output .= $image . '<br/>';
                        }

                        $output .= $news_heading;



                        $output .='</li>';

                        $i++;

                        if ($category != 0 && $i == 7) {
                            $output .='<li>See more news <a href="showNews.php?category=' . $category . '">here.</a></li>';
                            break;
                        }
                    }
                    $output .='</ul>';

                    return $output;
                }

                $feed_url = "http://rss.bdnews24.com/rss/getfeed.php?ln=en&cid=0&ct=n";
                $top_news = feed_to_html($feed_url, 0);

                $feed_url = "http://rss.bdnews24.com/rss/getfeed.php?ln=en&cid=2&ct=n";
                $bangladesh_news = feed_to_html($feed_url, 2);

                $feed_url = "http://rss.bdnews24.com/rss/getfeed.php?ln=en&cid=3&ct=n";
                $politics_news = feed_to_html($feed_url, 3);

                $feed_url = "http://rss.bdnews24.com/rss/getfeed.php?ln=en&cid=4&ct=n";
                $business_news = feed_to_html($feed_url, 4);

                $feed_url = "http://rss.bdnews24.com/rss/getfeed.php?ln=en&cid=5&ct=n";
                $sport_news = feed_to_html($feed_url, 5);

                $feed_url = "http://rss.bdnews24.com/rss/getfeed.php?ln=en&cid=1&ct=n";
                $world_news = feed_to_html($feed_url, 1);

                $feed_url = "http://rss.bdnews24.com/rss/getfeed.php?ln=en&cid=26&ct=n";
                $cricket_news = feed_to_html($feed_url, 26);
                ?>
            </div>



            <div id="topNews">
                <h2 class="label1">Today's Top News</h2>
                <?php echo $top_news; ?>
                <p class="clearfix"></p>
            </div>


            <div id="othersNews">
                <table>
                    <tr>
                        <td>
                            <h2 class="label2">Contry's News</h2>
                            <?php echo $bangladesh_news; ?> 
                        </td>
                        <td>
                            <h2 class="label2">News of Politics</h2>
                            <?php echo $politics_news; ?> 
                        </td>
                        <td>
                            <h2 class="label2">News of Bussiness</h2>
                            <?php echo $business_news; ?> 
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h2 class="label2">Sports News</h2>
                            <?php echo $sport_news; ?>
                        </td>
                        <td>
                            <h2 class="label2">World News</h2>
                            <?php echo $world_news; ?>
                        </td>
                        <td>
                            <h2 class="label2">Cricket News</h2>
                            <?php echo $cricket_news ?>
                        </td>
                    </tr>
                </table>
            </div>
            <br/>


            <div id="photoGallery">
                <?php
                $feed_url = "http://rss.bdnews24.com/rss/getfeed.php?ln=en&cid=2&ct=p";
                $content = file_get_contents($feed_url) . '</rss>';
                $xml_data = new SimpleXMLElement($content);

                $output = '<ul style="list-style:none">';
                $i = 0;
                foreach ($xml_data->content->item as $photo) {

                    $output .='<li>';
                    $caption = $photo->caption;
                    $thumbnail = $photo->thumbnail;
                    $link = $photo->link;
                    $img_id = substr($link, 42, 19);

                    $j = strpos($caption, " ", 50);
                    
                    $img_caption = substr($caption, 0, $j);

                    $img_caption .= ' <a href="viewPhoto.php?id=' . $img_id . '"><i>see more</i></a>';



                    $img_src = '<img src="' . $thumbnail . '"/>';
                    $img_src = '<a href="viewPhoto.php?id=' . $img_id . '">' . $img_src . '</a>';

                    $output .= $img_src . '<br/>';
                    $output .= $img_caption;

                    $output .='</li>';
                    $i++;

                    if ($i == 10) {
                        break;
                    }
                }
                $output .='</ul>';
                ?>

                <h2 class="label1"><a href="photoGallery.php">Today's Popular Photos</a></h2>
                <?php echo $output; ?>

                <p class="clearfix"></p>
                <br/>
                <div align="center">
                    <a href="photoGallery.php" class="readmore">See more photo here.</a>
                </div>
            </div>

            <br/>


            <div id="videoGallery">
                <?php
                $feed_url = "http://rss.bdnews24.com/rss/getfeed.php?ct=v&ln=en";
                $content = file_get_contents($feed_url) . '</rss>';
                $xml_data = new SimpleXMLElement($content);

                $output = '<ul style="list-style:none">';
                $i = 0;
                foreach ($xml_data->content->item as $video) {

                    $output .='<li>';
                    $thumbnail = $video->thumb;
                    $link = $video->link;
                    $video_id = substr($link, 25, 11);

                    $video_src = '<img src="' . $thumbnail . '"/>';

                    $video_src = '<a href="viewVideo.php?id=' . $video_id . '"> <span class="vcontainer">
                        </span>' . $video_src . '</a>';

                    $output .= $video_src . '<br/>';

                    $output .='</li>';
                    $i++;

                    if ($i == 10) {
                        break;
                    }
                }
                $output .='</ul>';
                ?>

                <h2 class="label1"><a href="videoGallery.php">Today's Popular Video</a></h2>
                <?php echo $output; ?>

                <p class="clearfix"></p>
                <br/>
                <div align="center">
                    <a href="videoGallery.php" class="readmore">watch more videos here.</a>
                </div>
            </div>

        </div>

        <br/><br/>

        <div class="fb-like"  data-width="300" ></div>

    </body>
</html>
